FROM registry.openanolis.cn/openanolis/anolisos:23

LABEL \
        maintainer="OpenAnolis Cloud Native SIG" \
        org.opencontainers.image.title=sonarqube \
        org.opencontainers.image.version=8.9.3

ARG SONARQUBE_VERSION=8.9.3.48735
ENV SONARQUBE_HOME=/opt/sonarqube \
    SQ_DATA_DIR="/opt/sonarqube/data" \
    SQ_EXTENSIONS_DIR="/opt/sonarqube/extensions" \
    SQ_LOGS_DIR="/opt/sonarqube/logs" \
    SQ_TEMP_DIR="/opt/sonarqube/temp"

RUN set -eux; \
    groupadd --system --gid 1000 sonarqube; \
    useradd --system --uid 1000 --gid sonarqube sonarqube; \
    yum -y update; \ 
    yum -y install anolis-epao-release; \
    yum -y install java-11-alibaba-dragonwell; \
    yum -y install sonarqube; \
    yum clean all; \ 
    mv /usr/share/sonarqube ${SONARQUBE_HOME}; \
    rm -rf ${SONARQUBE_HOME}/bin/*; \
    ln -s ${SONARQUBE_HOME}/lib/sonar-application-${SONARQUBE_VERSION}.jar ${SONARQUBE_HOME}/lib/sonarqube.jar; \
    chmod -R 555 ${SONARQUBE_HOME}; \
    chmod -R ugo+wrX "${SQ_DATA_DIR}" "${SQ_EXTENSIONS_DIR}" "${SQ_LOGS_DIR}" "${SQ_TEMP_DIR}"; \
    chown -R sonarqube:sonarqube ${SONARQUBE_HOME};  

COPY docker-entrypoint.sh ${SONARQUBE_HOME}/docker/
RUN chown -R sonarqube:sonarqube ${SONARQUBE_HOME}/docker;

WORKDIR ${SONARQUBE_HOME}

USER sonarqube

EXPOSE 9000

STOPSIGNAL SIGINT

ENTRYPOINT ["/opt/sonarqube/docker/docker-entrypoint.sh"]